From: Daiki Ueno Date: Wed, 22 Aug 2012 08:59:45 +0000 (+0900) Subject: st-im-text: Support pre-edit X-Git-Tag: archive/raspbian/50.5-1+rpi1~1^2~1013^2^2~6020 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=ee6086373b30d73c0413237a70705a7b303f38f3;p=gnome-shell.git st-im-text: Support pre-edit Use clutter_text_set_preedit_string() to wedge pre-edit text into ClutterText. https://bugzilla.gnome.org/show_bug.cgi?id=664041 --- diff --git a/src/st/st-im-text.c b/src/st/st-im-text.c index a3ff24de6..d5e287a42 100644 --- a/src/st/st-im-text.c +++ b/src/st/st-im-text.c @@ -81,6 +81,9 @@ static void st_im_text_commit_cb (GtkIMContext *context, const gchar *str, StIMText *imtext); +static void st_im_text_preedit_changed_cb (GtkIMContext *context, + StIMText *imtext); + G_DEFINE_TYPE (StIMText, st_im_text, CLUTTER_TYPE_TEXT) static void @@ -93,6 +96,9 @@ st_im_text_dispose (GObject *object) g_signal_handlers_disconnect_by_func (priv->im_context, (void *) st_im_text_commit_cb, object); + g_signal_handlers_disconnect_by_func (priv->im_context, + (void *) st_im_text_preedit_changed_cb, + object); g_object_unref (priv->im_context); priv->im_context = NULL; @@ -140,6 +146,29 @@ st_im_text_commit_cb (GtkIMContext *context, } } +static void +st_im_text_preedit_changed_cb (GtkIMContext *context, + StIMText *imtext) +{ + ClutterText *clutter_text = CLUTTER_TEXT (imtext); + gchar *preedit_str = NULL; + PangoAttrList *preedit_attrs = NULL; + gint cursor_pos = 0; + + gtk_im_context_get_preedit_string (context, + &preedit_str, + &preedit_attrs, + &cursor_pos); + + clutter_text_set_preedit_string (clutter_text, + preedit_str, + preedit_attrs, + cursor_pos); + + g_free (preedit_str); + pango_attr_list_unref (preedit_attrs); +} + static void reset_im_context (StIMText *self) { @@ -445,6 +474,8 @@ st_im_text_init (StIMText *self) priv->im_context = gtk_im_multicontext_new (); g_signal_connect (priv->im_context, "commit", G_CALLBACK (st_im_text_commit_cb), self); + g_signal_connect (priv->im_context, "preedit-changed", + G_CALLBACK (st_im_text_preedit_changed_cb), self); } /**